package com.manager.commons.basemanage.dao;

import java.util.List;

import com.manager.BaseDao;
import com.manager.commons.basemanage.entity.BaseData;
import com.manager.commons.basemanage.entity.BaseDataList;

/**
 * 
 * @author Administrator
 * 
 */
public class BaseDataDao extends BaseDao {

	public List<BaseDataList> BaseDataListList(Long baseDataId) {
		return this.getHibernateTemplate().find(
				"from BaseDataList where TId=" + baseDataId);
	}

	public List<BaseDataList> getBaseDataByTypeName(String typeName) {
		String sql = "from BaseDataList where TId=(select id from BaseData where typeName='"
				+ typeName + "')";
		return (List<BaseDataList>) this.getHibernateTemplate().find(sql);
	}

	public List<BaseData> searchBaseData(BaseData baseData) {
		String sql = "from BaseData where " + "typeName like '%"
				+ baseData.getTypeName() + "%' ";
		return this.getHibernateTemplate().find(sql);
	}

	public List<BaseDataList> searchBaseDataList(String selectValue, String TId) {
		String sql = "from BaseDataList where TId=" + TId + "";
		if (selectValue != null && !selectValue.equals("")) {
			sql += " and ListName like '%" + selectValue + "%'";
		}
		return this.getHibernateTemplate().find(sql);
	}
}
